using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using Credinka.Ayni.SEA.EN;
using Credinka.Ayni.SEA.AD;
namespace Credinka.Ayni.SEA.RN
{
    public class rnFormulario : rnGeneral
    {
        adFormulario oadFormulario;

        public List<enFormulario> Listar(enFormulario poenFormulario)
        {
            List<enFormulario> loenFormulario = null;
            using (SqlConnection con = new SqlConnection(sConexion))
            {
                try
                {
                    con.Open();
                    loenFormulario = new List<enFormulario>();
                    oadFormulario = new adFormulario(con);
                    loenFormulario = oadFormulario.fListar(poenFormulario);
                }
                catch (SqlException ex)
                {
                }
            }
            return (loenFormulario);
        }

        public List<enFormulario> Listar()
        {
            List<enFormulario> loenFormulario = null;
            using (SqlConnection con = new SqlConnection(sConexion))
            {
                try
                {
                    con.Open();
                    loenFormulario = new List<enFormulario>();
                    oadFormulario = new adFormulario(con);
                    loenFormulario = oadFormulario.fListar();
                }
                catch (SqlException ex)
                {
                }
            }
            return (loenFormulario);
        }

        public enFormulario Obtener(enFormulario poenFormulario)
        {
            enFormulario oenFormulario = null;
            using (SqlConnection con = new SqlConnection(sConexion))
            {
                try
                {
                    con.Open();
                    oenFormulario = new enFormulario();
                    oadFormulario = new adFormulario(con);
                    oenFormulario = oadFormulario.fObtener(poenFormulario);
                }
                catch (SqlException ex)
                {
                }
            }
            return oenFormulario;
        }

        public int Registrar(enFormulario poenFormulario)
        {
            int N = -1;
            using (SqlConnection con = new SqlConnection(sConexion))
            {
                try
                {
                    con.Open();
                    oadFormulario = new adFormulario(con);
                    N = oadFormulario.fRegistrar(poenFormulario);
                }
                catch (SqlException ex)
                {
                }
            }
            return (N);
        }

        public int Modificar(enFormulario poenFormulario)
        {
            int N = -1;
            using (SqlConnection con = new SqlConnection(sConexion))
            {
                try
                {
                    con.Open();
                    oadFormulario = new adFormulario(con);
                    N = oadFormulario.fModificar(poenFormulario);
                }
                catch (SqlException ex)
                {
                }
            }
            return (N);
        }

        public int Eliminar(enFormulario poenFormulario)
        {
            int N = -1;
            using (SqlConnection con = new SqlConnection(sConexion))
            {
                try
                {
                    con.Open();
                    oadFormulario = new adFormulario(con);
                    N = oadFormulario.fEliminar(poenFormulario);
                }
                catch (SqlException ex)
                {
                }
            }
            return (N);
        }

        public int Contar()
        {
            int totalFormulario = -1;
            using (SqlConnection con = new SqlConnection(sConexion))
            {
                try
                {
                    con.Open();
                    oadFormulario = new adFormulario(con);
                    totalFormulario = oadFormulario.fContar();
                }
                catch (SqlException ex)
                {
                }
            }
            return (totalFormulario);
        }
    }
}
